package com.example.base;

/**
 * 功能描述 
 * @author Lockon.wang
 */
public class TestString {

    public static void main(String[] args) {


        /**
         * 版本<=JDK 1.6:字符串常量池--永久代；
         * 版本>=JDK 1.7:字符串常量池--堆；
         */
        String s1 = new String("hello") + new String(" java");
        s1.intern();
        String s2 = "hello java";
        System.out.println("s1.intern()==s2: " + (s1.intern()==s2));
        System.out.println("s1==s2: " + (s1==s2));
        String s3 = new String("hello");
        s3.intern();
        String s4 = "hello";
        System.out.println("s3.intern()==s4: " + (s3.intern()==s4));
        System.out.println("s3==s4: " + (s3==s4));

    }
}
